package com.csweimei.rentmanagementtreasure.adapter;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.http.postBean.PostRoomBean;

public class HouseHzAdapter extends BaseQuickAdapter<PostRoomBean,BaseViewHolder> {
    public HouseHzAdapter() {
        super(R.layout.item_house_add_hz);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, PostRoomBean roomBean) {
        baseViewHolder.setText(R.id.tv_num,"房间"+(getItemPosition(roomBean)+1));

        EditText edtRoom = baseViewHolder.getView(R.id.edt_room);
        EditText edtRent = baseViewHolder.getView(R.id.edt_rent);
        EditText edtDeposit = baseViewHolder.getView(R.id.edt_deposit);

        roomBean.setNum("房间"+(getItemPosition(roomBean)+1));


        edtRoom.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                roomBean.setRoom(s.toString());
            }
        });

        edtRent.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                roomBean.setRent(s.toString());
            }
        });

        edtDeposit.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                roomBean.setDeposit(s.toString());
            }
        });

    }
}
